const Cart = {
	namespaced: true,
	state : {
		cartList : [] ,//购物车数据
		goodsList : []  //商品数据
	},
	mutations : {
		addGoods(state,list){
			state.goodsList = list
		},
		addCart(state,goods){
			let rel = true
			state.cartList.map(item => {
				if(item.goods.id === goods.id){
					item.num++
					rel = false
				}
			})
			
			if(rel){
				state.cartList.push({
					goods,
					num : 1
				})
			}
		},
		CarDel(state,index){
			state.cartList.splice(index,1)
		}
	},
	acitons : {
		
	}
}

export default Cart;